package com.yyl.main

import kotlinx.coroutines.*
import org.junit.Test

class CoroutineTest1 {

    private var coroutine= CoroutineScope(Dispatchers.IO)

    @Test
     fun test1(){
        val id1=  Thread.currentThread().id
        val name1=  Thread.currentThread().name
        coroutine.launch {
          val id2=  Thread.currentThread().id
          val name2=  Thread.currentThread().name
//            println("id1=$id1 name1=$name1")
//            println("id2=$id2 name2=$name2")
            println("event1")
            delay(1000)
            println("event2")
            delay(1000)
            println("event3")
        }
//        Thread.sleep(1100)
//        coroutine.cancel()
        coroutine.launch {
            println("event 11")
            delay(1000)
            println("event 22")
            delay(1000)
            println("event 33")
        }
        println("finish")
        Thread.sleep(5000)
    }

    suspend fun demo1(){

    }

}